import IndexModel from "@/models";
import '@/less/common.less';

export default class App {
  constructor($, options) {
    this.$app = $('<div id="app">');

    this.swiper = options.swiper;
    this.phone = options.phone;
    this.field = options.field;

    // 后端接口数据的缓存
    this.cache = null;

    this.init();
  }

  async init() {
    await this.getDatas();
    this.render();
  }

  async getDatas() {
    await IndexModel.getDatas({
      swiper: this.swiper,
      phone: this.phone,
      field: this.field,
    }).then((res) => {
      this.cache = {
        phoneDatas: res.phone_data,
        fieldDatas: res.field_data,
        swiperDatas: res.swiper_data,
      };
    });
  }
}
